package com.ruoyi.domain.common;



public class UserHolder {
    private static final ThreadLocal<Integer> threadLocal =  new ThreadLocal<>();
    //设置用户id到ThreadLocal中
    public static void setUserId(Integer id){
        threadLocal.set(id);
    }

    //从ThreadLocal中获取用户id
    public static Integer getUserId(){
        return threadLocal.get();
    }

    //移除ThreadLocal对象
    public static void removeThreadLocal(){
        threadLocal.remove();
    }
}